package com.itcast.mapper;

import com.itcast.pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.io.IOException;
import java.util.List;

@Mapper
public interface DeptMapper {
    /**
     * 部门列表
     * @return
     * @throws IOException
     */
//    @Select("select id, name, create_time, update_time from dept")
    List<Dept> findAll();

    /**
     * 删除部门
     * @param id
     * @return
     */
    @Delete("delete from dept where id = #{id}")
    void delete(Integer id);

    /**
     * 新增部门
     * @param dept
     * @return
     */
    @Insert("insert into dept(name, create_time, update_time) values (#{name},now(),now())")
    void add(Dept dept);

    /**
     * 根据id查找
     * @param id
     * @return
     */
    @Select("select id, name, create_time, update_time from dept where id = #{id}")
    Dept getById(Integer id);

    /**
     * 修改部门
     * @param dept
     * @return
     */
//    @Update("update dept set name = #{name},update_time = now() where id = #{id}")
    void update(Dept dept);
}
